package com.wc.alorithm_luogu._数学知识.P1036;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;

public class Main {
    public static void main(String[] args) {
        Input sc = new Input();

        int n = sc.nextInt();
        int k = sc.nextInt();

        Main main = new Main();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        System.out.println(main.primeNum(array, 0, 0, k));
    }

    public int primeNum(int[] array, int index, int sum, int floor) {

        if (floor == 0) {
            if (isPrime(sum)) {
                return 1;
            } else {
                return 0;
            }
        }
        if (index == array.length) {
            return 0;
        }
        int ans = 0;
        ans += primeNum(array, index + 1, sum + array[index], floor - 1);
        ans += primeNum(array, index + 1, sum, floor);

        return ans;
    }

    public boolean isPrime(int num) {
        if (num <= 1) {
            return false;
        } else if (num == 2) {
            return true;
        }
        int mid = (int) Math.sqrt(num);

        for (int i = 2; i <= mid; i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }

            return (int) in.nval;
        }
    }
}
